// PointLight.cpp
// Object which holds information for a point light.
//
// Nick Kitten
// 2009

#include "PointLight.h"

// Constructor - the color values must be in the range -255 to 255
PointLight::PointLight( int id, float x, float y, float z, int r, int g, int b )
: Object( id, x, y, z )
{
	dbMakeLight( ID );
	setPosition( x, y, z );
	setColor( r, g, b );
}

PointLight::~PointLight()
{
	dbDeleteLight( ID );
}

PointLight::PointLight( int id, Triple pos, DWORD col )
: Object( id, pos )
{
	dbMakeLight( ID );
	setPosition( pos.x, pos.y, pos.z );
	setColor( col );
}

void PointLight::setPosition( float x, float y, float z )
{
	Object::setPosition( x, y, z );
	dbPositionLight( ID, x, y, z );
}

void PointLight::setColor( int r, int g, int b )
{
	color.r = r;
	color.g = g;
	color.b = b;
	dbColorLight( ID , r, g, b );
}

void PointLight::setColor( DWORD col )
{
	color.r = ( 0xFF0000 & col ) >> 16;
	color.g = ( 0xFF00 & col ) >> 8;
	color.b = 0xFF & col;
	dbColorLight( ID, col );
}

Color PointLight::getColor() const
{
	return color;
}